package br.com.fiap.vendas.business.delegate;

import java.util.List;

import br.com.fiap.vendas.business.exception.ServiceException;
import br.com.fiap.vendas.business.service.interfaces.ClienteService;
import br.com.fiap.vendas.business.vo.ClienteVO;
import br.com.fiap.vendas.common.locator.ServiceLocator;

public class ClienteDelegate {
	
	private ServiceLocator locator;
	private ClienteService clienteService;
	
	public ClienteDelegate() {
		this.locator = ServiceLocator.getInstance();
	}

	private ClienteService getService() {
		if (this.clienteService == null) {
			this.clienteService = (ClienteService) locator
					.lookup(ClienteService.JNDI_NAME);
		}
		return clienteService;
	}

	public void inserirCliente(ClienteVO clienteVO) throws ServiceException {

		getService().inserirCliente(clienteVO);

	}

	public List<ClienteVO> listarClientes() throws ServiceException {
		return getService().listarClientes();
	}
	
	public List<ClienteVO> buscarClientesComPedidos() throws ServiceException {
		return getService().buscarClientesComPedidos();
	}



}
